/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2022-06-21 14:28:39
 * @LastEditors: TT
 * @LastEditTime: 2022-07-11 16:38:41
 */

import 'package:flutter/material.dart';
import 'package:hzy_normal_widget/hzy_getx_utils.dart';
import 'package:hzy_template/components/common_state_widget.dart';
import 'package:hzy_template/config/dataconfig/data_config_index.dart';
import 'package:hzy_template/config/dataconfig/language_info_config.dart';
import 'package:ttcomment/ttcomment.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../config/models/normmal_title_item_model.dart';
import '../models/my_data.dart';

class MyGeneralPage extends TTNormalStatefulWidget {
  const MyGeneralPage({Key? key}) : super(key: key);

  @override
  TTNormalState<TTNormalStatefulWidget> getState() {
    return _MyGeneralPageState();
  }
}

class _MyGeneralPageState extends CommonStateWidget<MyGeneralPage> {
  /// 属性
  ///
  ///

  @override
  String? get title => LauchNormalMsg.general;
  @override
  Color? get backgroundColor => HzyColorConfig().backgroudgrey;
  @override
  Color? get navbackcolor => HzyColorConfig().backgroudgrey;
  List<NormalTitleItemModel> get list => MyData().confignewgenerallistInfo();

  /// 生命周期
  ///
  ///

  /// 网路请求
  ///
  ///

  /// 构建视图
  ///
  ///

  @override
  Widget createBody(BuildContext context) {
    return ListView.separated(
      itemBuilder: createItemBuilder,
      separatorBuilder: createSeparatorBuilder,
      itemCount: list.length,
    );
  }

  Widget createItemBuilder(BuildContext context, int index) {
    NormalTitleItemModel itemModel = list[index];
    if (itemModel.isbox ?? false) {
      return SizedBox(
        height: itemModel.boxheight,
      );
    } else {
      return CreateNormalItemWidget(
        leftwidget: Text(
          itemModel.leftmsg ?? "",
          style: FontConfig().fontMedium14Black,
        ),
        isshowline: itemModel.showline,
        isshownext: itemModel.isshownext,
        istap: itemModel.istap,
        index: index,
        backgroundColor: HzyColorConfig().whitebackgroundColor,
        arrowrightwidget: Padding(
          padding: EdgeInsets.only(left: 5.w, right: 10.w),
          child: Icon(
            Icons.arrow_forward_ios,
            size: 16.w,
          ),
        ),
        rightwidget: Text(
          itemModel.rightmsg ?? "",
          style: FontConfig().fontMedium14Grey,
        ),
        ontap: (value) {
          currentToPage(itemModel.pageid ?? "");
        },
      );
    }
  }

  Widget createSeparatorBuilder(BuildContext context, int index) {
    return Container();
  }

  /// 触发方法
  ///
  ///

  /// 配置默认数据
  @override
  void configNormalData() {}
}
